/******************************************************************************
 Copyright (c) 2024 Qualcomm Technologies International, Ltd.
 All Rights Reserved.
 Qualcomm Technologies International, Ltd. Confidential and Proprietary.

******************************************************************************/

#include "csr_pmem.h"

#define ID3V2_TAG_HEADER_LENGTH 10
#define ID3V2_TAG_HEADER_IDENTIFIER_LENGTH 3
#define ID3V2_TAG_HEADER_MAJOR_VERSION_LENGTH 1
#define ID3V2_TAG_HEADER_MINOR_VERSION_LENGTH 1
#define ID3V2_TAG_HEADER_FLAGS_LENGTH 1
#define ID3V2_TAG_HEADER_TAG_SIZE_LENGTH 4
#define ID3V2_EXTENDED_HEADER_SIZE_LENGTH 4

#define ID3V2_FRAME_HEADER_ID_LENGTH 4
#define ID3V2_FRAME_HEADER_SIZE_LENGTH 4
#define ID3V2_FRAME_HEADER_FLAGS_LENGTH 2

#define ID3v2_FRAME_HEADER_LENGTH (ID3V2_FRAME_HEADER_ID_LENGTH + ID3V2_FRAME_HEADER_SIZE_LENGTH + ID3V2_FRAME_HEADER_FLAGS_LENGTH)

/*
In future may need to extend for below to get
#define ID3v2_COMPOSER_FRAME_ID       (frameId(0x00))
#define ID3v2_GENRE_FRAME_ID          (frameId(0x00))
*/

/* Reserved for future purpose when utility wants to store tag header information */
typedef struct ID3v2TagHeader
{
    uint8 identifier[ID3V2_TAG_HEADER_IDENTIFIER_LENGTH];
    uint8 major_version;
    uint8 minor_version;
    uint8 flags;
    uint32 tag_size;
    uint32 extended_header_size;
} ID3v2TagHeader;

/* Reserved for future purpose when utility wants to store tag header information */
typedef struct ID3v2_FrameHeader
{
    uint32 size;      /* Frame size */
    uint8 id[ID3V2_FRAME_HEADER_ID_LENGTH];   /*------> frame id*/
    uint8 flags[ID3V2_FRAME_HEADER_FLAGS_LENGTH];
} ID3v2FrameHeader;

/* Reserved for future purpose when utility wants to store tag header information */
typedef struct ID3v2Frame
{
    ID3v2FrameHeader* header;
    void* data;
} ID3v2Frame;

/* Reserved for future purpose when utility wants to store tag header information */
typedef struct ID3v2FrameList
{
    ID3v2Frame* frame;
    struct ID3v2FrameList* start;
    struct ID3v2FrameList* next;
} ID3v2FrameList;

/* Reserved for future purpose when utility wants to store tag header information */
typedef struct ID3v2Tag
{
    ID3v2TagHeader* header;
    ID3v2FrameList* frames;
    uint32 frameCount;
    uint32 padding_size;
} ID3v2Tag;
